package com.example.demo.controller;

import com.example.demo.dao.PersonRepository;
import com.example.demo.dao.UserRepository;
import com.example.demo.entity.Person;
import com.example.demo.entity.View;
import com.example.demo.service.ViewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.Query;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/")

public class PersonController {
//    @Autowired
//    PersonRepository personRepository;
//    @Autowired
//    UserRepository userRepository;

    @Autowired
    ViewService viewService;

    /**
     *
     * @param card
     * @return
     */
    @RequestMapping("/t")
    public List<Person> test(@RequestParam("card") Long card){
        System.out.println(card);
        List<Person> test1 = viewService.test(card);
        return test1;

    }

//    @RequestMapping("/t1")
//    public List<View> test(){
//        List<View> viewp = personRepository.findViewp() ;
//        //List<View> viewu = personRepository.findViewu();
////        for(View view : views){
////            System.out.println(view.getPerson());
////            System.out.println(view.getUser());
////        }
//        return viewp;
//    }

//    @RequestMapping("/login")
//    public String log(){
//        return "login";
//    }
//    @RequestMapping("/")
//    public String ok(){
//        return  "one";
//    }


//    @RequestMapping(value="/login",method = RequestMethod.POST)
////    public String login(Person person){
////
////        return "/login";
////    }
}
